<%@ page language = "java" %>
<%@ page import = "java.util.*" %>
<%@ page import = "edu.colorado.karl.login.ChangePassword" %>
<%@ page import = "javax.servlet.http.Cookie" %>

<%@ include file = "header.jspf" %>

<%
ChangePassword c = ChangePassword.getChangePassword();
String new_pass = request.getParameter("new_password");
String conf = request.getParameter("confirm");
String str = "";

cookies = request.getCookies();

if(cookies != null && cookies.length == 2)
{
  name = cookies[1].getName();
}

if(new_pass.compareTo(conf) == 0)
{
  if((new_pass.length()) < 6 || (new_pass.length() > 12))
  {
    out.println("Error, new password must be 6 - 12 characters long.<BR>");
  }

  else
  {
    c.sqlConnect();
    c.changePass(name,new_pass);
    out.println("Password successfully changed.<BR>");
    out.println("<meta http-equiv=REFRESH content=0;url=index.jsp>");
  }
}

else
{
  out.println("Error, new password and confirm fields do not match.");
}

%>

<%@ include file = "footer.jspf" %>
